package com.itheima.health.controller;

import com.itheima.health.common.MessageConst;
import com.itheima.health.entity.Result;
import com.itheima.health.pojo.Setmeal;
import com.itheima.health.service.SetmealService;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author: liangWeiQUQ
 * @Description: TODO
 * @DateTime: 2021/3/4 9:42
 **/
@RestController
@Slf4j
@RequestMapping("/mobile/setmeal")
public class SetmealController {
    @DubboReference
    private SetmealService setmealService;
    
    /**
             * @Author: 传闻中的梁大侠 
             * @Date: 10:09 2021/3/4
             * @Parms []
             * @ReturnType: com.itheima.health.entity.Result
             * @Description: 查询所有的套餐服务列表
            */
    
    @RequestMapping("/getSetmeal")
    public Result getSetmeal() {
        //rpc调用查询所有套餐
        List<Setmeal> setmeals = setmealService.findAll();
        return new Result(true, MessageConst.GET_SETMEAL_LIST_SUCCESS,setmeals);
    }

    @RequestMapping("/findById")
    /**
             * @Author: 传闻中的梁大侠
             * @Date: 10:18 2021/3/4
             * @Parms []
             * @ReturnType: com.itheima.health.entity.Result
             * @Description: 根据id查询套餐信息
            */

    public Result findById(Integer id) {
        //调用rpc完成数据的查询
        Setmeal setmeal = setmealService.findById(id);
        return new Result(true, MessageConst.QUERY_SETMEAL_SUCCESS, setmeal);
    }



}
